package prefuse.tp.svn;

import prefuse.Constants;
import prefuse.data.Edge;
import prefuse.data.Node;
import prefuse.render.EdgeRenderer;
import prefuse.visual.VisualItem;

/**
 * Set edge
 */
public class GraphRadial_edgeRenderer extends EdgeRenderer{
	public GraphRadial_edgeRenderer(int EdgeType){
		super(EdgeType);
		setEdgeType(Constants.EDGE_TYPE_CURVE);
       // setHorizontalAlignment1(Constants.BOTTOM);
       // setVerticalAlignment1(Constants.BOTTOM);
        setManageBounds(true);
        //setDefaultLineWidth(2.0f);
        setDefaultLineWidth(.5f);
	}
	
    protected double getLineWidth(VisualItem item) {
    	if(item.getSourceTuple() instanceof Edge){
    		if(nodeSelected != null){
		    	Edge e = (Edge) item.getSourceTuple();
		    	if(e.getSourceNode().equals(nodeSelected))
		    	        return 5*item.getSize();
		    	if(e.getTargetNode().equals(nodeSelected))
	    	        return 5*item.getSize();
	    	}
    		Node n = ((Edge)(item.getSourceTuple())).getSourceNode();
    		switch(n.getInt("type")){
    		case GraphRadial_Affectations.MASTER:
    	        return 6*item.getSize();
    		case GraphRadial_Affectations.MENTION:
    	        return 4*item.getSize();
    		case GraphRadial_Affectations.SPECIALITE:
    	        return 2*item.getSize();
    		case GraphRadial_Affectations.ETUDIANT:
    	        return .1*item.getSize();
    		}
    	}
    	
        return item.getSize();
    }
    Node nodeSelected;
	public void setItemSelected(Node n) {
			nodeSelected = n;
		//	System.out.println(n);
	}
	
}